﻿using System;
using System.Collections;

namespace arrayListTest
{
    class Program
    {
        static void Main(string[] args)
        {//1
            Console.WriteLine("firstLesson");
            Console.WriteLine();
            ArrayList list = new ArrayList() { "123","abc","456"};
            int index = list.IndexOf("abc");
            if (index != -1)
            {
                Console.WriteLine("该集合中含有abc");
            }
            else
            {
                Console.WriteLine("该集合中不含有abc");
            }
            //2
            Console.WriteLine("");
            Console.WriteLine("seconLesson");
            ArrayList newList = new ArrayList();
            for(int i = 0; i < list.Count; i = i + 2)
            {
                newList.Add(list[i]);
            }
            foreach (var item in newList)
            {
                Console.WriteLine(item);
            }
            //3
            Console.WriteLine("");
            Console.WriteLine("sirstLesson");
            ArrayList arr = new ArrayList() { "qwe", "asd", "zxc" };
            list.InsertRange(1, arr);
            foreach (var item1 in list)
            {
                Console.WriteLine(item1);
            }
            //4
            Console.WriteLine();
            Console.WriteLine("nextlesson");
            arr.Sort();
            foreach (var item2 in arr)
            {
                Console.WriteLine(item2);
            }
            //5
            Console.WriteLine();
            Console.WriteLine("lastLesson");
            Compare compare = new Compare();
            compare.ICompare();
        }
        class Compare : ICompare{
            public void ICompare()
            {

                ArrayList arr3 = new ArrayList() { "qwe", "asd", "zxc" };
                arr3.Sort();
                foreach (var item3 in arr3)
                {
                    Console.WriteLine(item3);
                }
            }
        }
    }
    
}
